import { createRouter, createWebHistory } from 'vue-router'
import {useUserStore} from '@/stores/user'
import routes from './routes'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
 
   
  
})

router.beforeEach((to,from) => {
  const userStore = useUserStore()
  if(to.meta.keepAlive){
    if(!userStore.info.token){
      return '/login'
    }
  }
})

export default router
